How to set a selection / highlight text in a richText DBE

Is there anyway of highlighting a particular piece of text in a richText DBE?

I would like to be able to highlight an attribute search match, i.e. a portion of an attribute value.

Is there an equivalent of the getSelection perm that can be used on a richText DBE? Alternatively, does anyone know if I can format the richText so that it a section of the text can be highlighted somehow?


TheNybbler - Mon Jan 18 19:07:24 EST 2016

Re: How to set a selection / highlight text in a richText DBE
Mathias Mamsch - Tue Jan 19 02:23:26 EST 2016

You should be able to use \highlight1 with a colormap to set a highlight. There are examples on the forum. Look for highlight. Regards, Mathias

Re: How to set a selection / highlight text in a richText DBE
TheNybbler - Thu Jan 21 08:00:49 EST 2016

Mathias Mamsch - Tue Jan 19 02:23:26 EST 2016

You should be able to use \highlight1 with a colormap to set a highlight. There are examples on the forum. Look for highlight. Regards, Mathias

OK, so I have found some code elsewhere on the site that shows me how to set up colors.

But, something odd is going on. I can set the highlight color, but for some reason I cannot get the text color to work. It always displays in black.

Here is a snippet of my code:

 // RTF Color Table
  // 
  //  1: Black
  //  2: Red
  //  3: Green
  //  4: Blue
  //  5: Yellow
  //  6: Magenta
  //  7: Cyan
  //  8: White
  string colorTable = "{\\rtf1{\\colortbl;\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;\\red255\\green255\\blue0;\\red255\\green0\\blue255;\\red0\\green255\\blue255;\\red255\\green255\\blue255;}"; 
  string disp = colorTable;
  int i = 1; 
  for (i = 1; i < 9; i++)
  {
    disp = disp "{\\cf" i " Text Color " i "}\\line\\highlight" i " Highlight Color " i " \\highlight0\\line";
  } 
  disp = disp "}";

  print(disp);
  set(dbeResultsAttrContent, disp);

 

Re: How to set a selection / highlight text in a richText DBE
TheNybbler - Mon Jan 25 17:07:10 EST 2016

I have since discovered that there is a perm you can use:

void select(DBE dbe, int start, int end)